import App from './App'
import Vue from 'vue'
import mixins from '@/mixins/index.js'
Vue.mixin(mixins)
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
import store from "@/store/index.js"; //vuex
import i18n from '@/i18n/index.js' // 国际化
import http from '@/mixins/http.js'
http.config.baseUrl = "https://dlm.henatop.com/api/"; //请求地址域名
Vue.prototype.$IMG_URL = "https://dlm.henatop.com/api/"; //请求地址域名
Vue.prototype.$IMAGE_URL = "https://dlm.henatop.com/assets/img/image/"; //图片
Vue.prototype.$DOMAIN_URL = "https://dlm.henatop.com"; //图片拼接专用域名
Vue.prototype.$http = http
http.interceptor.request = (config) => {
	config.header = {
		"token": uni.getStorageSync('token')
	}
}
//设置请求结束后拦截器
http.interceptor.response = (response) => {
	if (response.data.code == 401) {
		uni.showToast({
			title: response.data.msg,
			icon: 'none'
		})
		store.dispatch('logout');
	}
	if (response.data.code == 0) {
		setTimeout(() => {
			uni.showToast({
				title: response.data.msg,
				icon: 'none'
			})
		}, 150)
	}
	return response;
}
//引入Vue
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype._i18n = i18n
const app = new Vue({
	...App,
	i18n,
	store
})
app.$mount()
